package com.vodone.v1pin.userInfo.delegate
{
	import com.vodone.v1pin.userInfo.vo.CouponVO;
	
	import mx.collections.ArrayCollection;

	public class CouponUtil
	{
		public static function getCouponListFromObj(obj:Object):ArrayCollection
		{
			var list:ArrayCollection = new ArrayCollection();
			if(obj && obj is Array)
			{
				var arr:Array = obj as Array;
				if(arr && arr.length > 0)
				{
					for(var i:int = 0; i< arr.length ; i++)
					{
						list.addItem(getCouponItem(arr[i]));
					}
				}
			}
			return list;
		}
		
		public static function getCouponItem(obj:Object):CouponVO
		{
			var item:CouponVO = new CouponVO();
			if(obj)
			{
				if(obj.hasOwnProperty("couponNum"))
				{
					item.couponCode = obj["couponNum"];
				}
				if(obj.hasOwnProperty("couponCode"))
				{
					item.couponCode = obj["couponCode"];
				}
				if(obj.hasOwnProperty("date"))
				{
					item.date = obj["date"];
				}
				if(obj.hasOwnProperty("explain"))
				{
					item.explain = obj["explain"];
				}
				if(obj.hasOwnProperty("money"))
				{
					item.money = obj["money"];
				}
				if(obj.hasOwnProperty("rule"))
				{
					item.rule = obj["rule"];
				}
				if(obj.hasOwnProperty("type"))
				{
					item.type = obj["type"];
				}
			}
			return item;
		}
	}
}